home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000
/
Ham Radio 2000.iso
/
ham2000
/
tcp_ip
/
rip2
/
ripdump.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-28
|
2KB
|
91 lines
/* RIP packet tracing
* Copyright 1991 Phil Karn, KA9Q
*
* Changes Copyright (c) 1993 Jeff White - N0POY, All Rights Reserved.
* Permission granted for non-commercial copying and use, provided
* this notice is retained.
*
* Rehack for RIP-2 (RFC1388) by N0POY 4/1993
*
* Beta release 9/8/93 V0.91
*
*/
#include "global.h"
#include "config.h"
#ifdef RIP
#include "mbuf.h"
#include "netuser.h"
#include "timer.h"
#include "rip.h"
#include "trace.h"
// from trace.c
void fmtline __ARGS((FILE *fp,int16 addr,char *buf,int16 len));
void
rip_dump(fp,bpp)
FILE *fp;
struct mbuf **bpp;
{
struct rip_route entry;
struct rip_authenticate *ripauth;
int i;
int cmd,version;
int16 len;
int16 domain;
char ipaddmask[25];
fprintf(fp,"RIP: ");
cmd = PULLCHAR(bpp);
version = PULLCHAR(bpp);
switch(cmd){
case RIPCMD_REQUEST:
fprintf(fp,"REQUEST");
break;
case RIPCMD_RESPONSE:
fprintf(fp,"RESPONSE");
break;
default:
fprintf(fp," cmd %u",cmd);
break;
}
domain = pull16(bpp);
len = len_p(*bpp);
fprintf(fp," vers %u entries %u domain %u:\n",version,len / RIP_ENTRY, domain);
i = 0;
while(len >= RIP_ENTRY){
/* Pull an entry off the packet */
pullentry(&entry,bpp);
len -= RIP_ENTRY;
if (entry.rip_family == RIP_AF_AUTH) {
continue;
}
if(entry.rip_family != RIP_AF_INET) {
/* Skip non-IP addresses */
continue;
}
if (version >= RIP_VERSION_2) {
sprintf(ipaddmask, "%s/%-4d", inet_ntoa(entry.rip_dest),
mask2width(entry.rip_dest_mask));
} else {
sprintf(ipaddmask, "%s/??", inet_ntoa(entry.rip_dest));
}
fprintf(fp,"%-20s%-3u",ipaddmask, entry.rip_metric);
if((++i % 3) == 0){
putc('\n',fp);
}
}
if((i % 3) != 0)
putc('\n',fp);
}
#endif /* RIP */